home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / sml_nj / cml-098.lha / cml-0.9.8 / examples / ex-primes.sml < prev    next >
Encoding:
Text File  |  1990-11-01  |  395 b   |  18 lines

  1. (* ex-primes.sml
  2.  *
  3.  * COPYRIGHT (c) 1990 by John H. Reppy.  See COPYRIGHT file for details.
  4.  *
  5.  * A simple stream-style program to generate primes.  This uses
  6.  * ex-counter.sml and ex-primes.sml.
  7.  *)
  8.  
  9. (* BEGIN EXAMPLE *)
  10. fun primes n = let
  11.       val ch = sieve ()
  12.       fun loop 0 = ()
  13.     | loop i = (CIO.print(makestring(accept ch)^"\n"); loop(i-1))
  14.       in
  15.     loop n
  16.       end
  17. (* END EXAMPLE *)
  18.